ChannelService    = Packages.com.google.appengine.api.channel.ChannelService;
ChannelServiceFactory = Packages.com.google.appengine.api.channel.ChannelServiceFactory;
ChannelMessage = Packages.com.google.appengine.api.channel.ChannelMessage;
function main( hh ) {
  /*
var json = ui.getFirst("json");
    if ( json == null ){
        var ex = "{ exception: { message: 'no param provided'} }";
        return ex;
  }
  */
 var userObject = hh.getFirst("json");
   Log.debug(userObject);
   if ( userObject == null ){
        var ex = "{ exception: { message: 'no param provided'} }";
        return ex;
  }
  
  var json = null;
  try{
     json = new JSONObject( userObject );
  } catch ( e ){
      Log.debug("Error in getting params",e);
      var ex = "{ exception: { message: '" + e + "'} }";
      return ex;
  }
  
  var userId;
  
  try{
      userId = json.get("userId");
  } catch ( e ){
      Log.debug("Error in getting params" + e);
      var ex = "{ exception: { message: '" + e + "'} }";
      return ex;
  }

  var channelService = ChannelServiceFactory.getChannelService();
  var token = channelService.createChannel(userId);

  return token;
  
}